package com.gzdh.tang.config;

import com.gzdh.tang.config.weixin.WXPayUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WeixinPayConfig {

    @Value("${weixin.pay.appid}")
    private String appid;

    @Value("${weixin.pay.mchId}")
    private String mchId;

    @Value(value = "${weixin.pay.subMchId}")
    private String subMchId;

    @Value("${weixin.pay.subAppid}")
    private String subAppid;

    @Value("${weixin.pay.keys}")
    private String keys;

    @Value("${weixin.pay.submchMode}")
    private int submchMode;

    @Value("${weixin.pay.refundNotifyUrl}")
    private String refundNotifyUrl;

    @Value("${weixin.pay.privateKey}")
    private String privateKey;

    @Value("${weixin.pay.merchantSerialNumber}")
    private String merchantSerialNumber;

    @Value("${weixin.pay.apiV3Key}")
    private String apiV3Key;

    @Value("${weixin.pay.merchantPublicKey}")
    private String merchantPublicKey;

    @Value("${weixin.pay.merchantPublicKeyId}")
    private String merchantPublicKeyId;

    @Value("${weixin.pay.prefix}")
    private String prefix;

    @Bean
    public void initWXPayUtils() {
        WXPayUtils.setAppid(appid);
        WXPayUtils.setKeys(keys);
        WXPayUtils.setMchId(mchId);
        WXPayUtils.setSubMchId(subMchId);
        WXPayUtils.setSubAppid(subAppid);
        WXPayUtils.setKeys(keys);
        WXPayUtils.setSubmchMode(submchMode);
        WXPayUtils.setRefundNotifyUrl(refundNotifyUrl);
        WXPayUtils.setPrivateKey(privateKey);
        WXPayUtils.setMerchantSerialNumber(merchantSerialNumber);
        WXPayUtils.setApiV3Key(apiV3Key);
        WXPayUtils.setMerchantPublicKey(merchantPublicKey);
        WXPayUtils.setMerchantPublicKeyId(merchantPublicKeyId);
        WXPayUtils.setPrefix(prefix);
    }
}
